type Node     native  // *vdom.Node
type Styles   native  // *vdom.Styles
type Attrs    native  // *vdom.Attrs
type Events   native  // *vdom.Events
type Content  native  // vdom.Content

type EventHandler native  // *vdom.EventHandler
type EventPayload native  // *qt.WebUiEventPayload (contains a C++ pointer)

/// Be careful!
/// Following constructors create pointers so that they are NOT pure operators.

/// Be careful!
/// The vDOM driver in `bridge.js` uses the memory address of a vNode as an ID.
/// Therefore, a vNode cannot be used more than once.
/// In addition, due to some restrictions, a vNode cannot move across subtrees.


public function
    Node { tag String } Node
    native('__UiVdomNode')

public function
    NodeWithText { tag Tag, text String } Node {
        (Node(tag) with (ContentText(text)))
    }

public function
    NodeWithChildren { tag Tag, children List[Node] } Node
        (Node(tag) with (ContentChildren(children)))
    }


public function
    Styles { styles Map[String,String] } Styles
    native('__UiVdomStyles')

public operator
    with { node Node, styles Styles } Node
    native('__UiVdomNodeWithStyles')


public function
    Attrs { attrs Map[String,String] } Attrs
    native('__UiVdomAttrs')

public operator
    with { node Node, attr Attrs } Node
    native('__UiVdomNodeWithAttrs')


public function
    Events { events Map[String,EventHandler] } Events
    native('__UiVdomEvents')

public function
    EventHandler[T] { k Lambda[T,Observable[None]], f Lambda[EventPayload,T] } Observable[EventHandler]
    native('__UiVdomEventHandler')
    // note: payload is deleted after the T value is sent to the sink

public operator
    with { node Node, events Events } Node
    native('__UiVdomNodeWithEvents')


public function
    ContentText { text String } Content
    native('__UiVdomText')

public function
    ContentChildren { children List[Node] } Content
    native('__UiVdomChildren')

public operator
    with { node Node, content Content } Node
    native('__UiVdomNodeWithContent')


public operator
    get-bool { ev EventPayload, key String } Bool
    native '__UiEventPayloadGetBool';

public operator
    get-string { ev EventPayload, key String } String
    native '__UiEventPayloadGetString';

public operator
    get-float { ev EventPayload, key String } Float
    native '__UiEventPayloadGetFloat';

public operator
    get-integer { ev EventPayload, key String } Int
    native '__UiEventPayloadGetInt';


